﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Nova_BLL;
using Nova_DAL;
using Nova_Common;
using Nova_MOD;
using System.Configuration;

public partial class LCDShow_LCDShow : System.Web.UI.Page
{
    //全局变量
    public string UsedStorageNum;   // 使用的货位数
    public string ResidueStorageNum; // 剩余的货位数
    //public List<Nova_MOD.LCDTask> listLCDTask=new List<Nova_MOD.LCDTask>(); //  LCD显示任务列表
    public Nova_MOD.LCDTask LCDTask1001 = new Nova_MOD.LCDTask();  //入库口显示任务
    public Nova_MOD.LCDTask LCDTask1101 = new Nova_MOD.LCDTask();  //拣选口显示任务
    public Nova_MOD.LCDTask LCDTask1003 = new Nova_MOD.LCDTask();  //出库口显示任务
    public string ShowLCDLogInfor;   //LCD显示重要提示信息
    
    //LCD显示提示信息的多少(3)分钟内的  
    private static readonly int LCDShowLogMinute = Convert.ToInt32(ConfigurationManager.AppSettings["LCDShowLogMinute"]);


    public Nova_BLL.TBase_Position TBasePositionbll = new Nova_BLL.TBase_Position();
    public Nova_BLL.LCDTaskbll LCDTaskbll = new LCDTaskbll();
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Timer1_Tick(object sender, EventArgs e)
    {
        RefStorageNum(); //刷新货位数信息
        RefLCDShowTask(); //刷新对应设备上的显示任务信息
        RefShowLCDLogInfor();//刷新LCD显示的提示信息
    }

    /// <summary>
    /// 刷新货位数信息
    /// </summary>
    public void RefStorageNum()
    {
        try
        {
            UsedStorageNum = TBasePositionbll.getUsedStorage().ToString();
            ResidueStorageNum = TBasePositionbll.getResidueStorage().ToString();
        }
        catch
        {
            UsedStorageNum = "-1";
            ResidueStorageNum = "-1";
        }


    }


    /// <summary>
    /// 刷新对应设备上的显示任务信息
    /// </summary>
    public void RefLCDShowTask()
    {

        try
        {
            List<Nova_MOD.LCDTask> listLCDTask = new List<Nova_MOD.LCDTask>(); //  LCD显示任务列表
            listLCDTask = LCDTaskbll.GetALLLCDTaskInfor();
            if(listLCDTask.Count>0)
            { 
                foreach(var item in listLCDTask)
                {
                    if (item.SQID==1001)
                    {
                        LCDTask1001 = item;
                    }
                    else if(item.SQID == 1003)
                    {
                        LCDTask1003 = item;
                    }
                    else if (item.SQID == 1101)
                    {
                        LCDTask1101 = item;
                    }

                }

            }

        }
        catch
        {
           
        }


    }

    /// <summary>
    /// 刷新LCD显示的提示信息
    /// </summary>
    public void RefShowLCDLogInfor()
    {
        try
        {
            ShowLCDLogInfor = LCDTaskbll.GetShowLCDLogInfor(LCDShowLogMinute);
            
        }
        catch
        {
            ShowLCDLogInfor = "获取LCD显示信息异常";
        }


    }

}